﻿using FileMonitor.Configuration.Prototype.Provider;

namespace FileMonitor.Configuration.Providers
{
    public class ProviderService
    {
        private static  PlantProcessConfigurationProvider plantProcessConfig;
        private static object lockObj = new object();
       
        public static IProvider GetProvider()
        {
            string xmlPath = System.Configuration.ConfigurationManager.AppSettings["XMLConfigPath"];
            string configProviderType = System.Configuration.ConfigurationManager.AppSettings["ConfigProviderType"].ToUpper();
            IProvider provider = null;
            switch (configProviderType)
            {
                case "XMLCONFIG":
                    provider = new XMLProvider(xmlPath);
                    break;
            }
            return provider;
        }

        public static IPlantProcessConfiguration GetPlantProcessConfigProvider()
        {
            if (plantProcessConfig == null)
            {
                lock (lockObj)
                {
                    if (plantProcessConfig == null)
                    {
                        plantProcessConfig=new PlantProcessConfigurationProvider();
                    }
                }
            }
            return plantProcessConfig;
        }
    }
}
